home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / waypoint.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  123 lines

  1. /* --------------------------------- waypoint.c ----------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* paint waypoint stuff on the Head Up Display.
  8. */
  9.  
  10. #include "plane.h"
  11.  
  12.  
  13. extern void FAR
  14. show_waypoint (HUD *h, VIEW *view, OBJECT *p)
  15. {
  16.     LVECT    *R;
  17.     OBJECT    *target;
  18.     VECT    RR;
  19.     int    D[2];
  20.     int    ind, out, x, y, tx, ty, rx, ry;
  21.     long    hx, hy, t;
  22.     ANGLE    a;
  23.  
  24.     if (!(EX->hud2 & HUD_WAYPOINT))
  25.         return;
  26.  
  27.     if (T(target = EX->target) && target->id == EX->tid) {
  28.         R = &target->R;
  29.         ind = 0;
  30.     } else {
  31.         ind = EX->ils;
  32.         if (ind < 1)
  33.             ind = 1;
  34.         R = &ils[ind-1].R;
  35.         ind = 1;
  36.     }
  37.  
  38. /* Object highlighting diamond.
  39. */
  40.     if (ind) {
  41.         tx = (h->dd+1)/2;
  42.         ty = (muldiv (h->dd, h->sy, h->sx)+1)/2;
  43.  
  44.         objects_show (1, view, p, 0, *R, RR);
  45.         if (h->flags & HF_ETHER) {
  46.             x = h->maxx;
  47.             y = h->maxy;
  48.         } else {
  49.             x = h->sx;
  50.             y = h->sy;
  51.         }
  52.         out = clip_to_screen (D, RR, h->maxx, h->maxy, x-tx,
  53.                 y-ty, h->shifty);
  54.         if (out && h->flags & HF_ETHER) {
  55.             clip_to_ether (h, D, x-tx, y-ty);
  56.             tx = h->ethertx;
  57.             ty = h->etherty;
  58.             out = 0;
  59.         }
  60.         D[X] = h->orgx + D[X];
  61.         D[Y] = h->orgy - D[Y];
  62.         show_diamond (D[X], D[Y], tx, ty, ST_HFG, out);
  63.     }
  64.  
  65. /* Object position pointer.
  66. */
  67.     hx = ((*R)[X] - p->R[X])/VONE;
  68.     hy = ((*R)[Y] - p->R[Y])/VONE;
  69.     t = labs(hx) + labs(hy);
  70.     while (t > 0x7fffL) {
  71.         hx >>= 1;
  72.         hy >>= 1;
  73.         t  >>= 1;
  74.     }
  75.     a = ATAN ((int)hx, (int)hy) + p->a[Z];
  76.  
  77.     tx = EX->ldstep + 2*EX->hudFontSize;
  78.     x = fmul (h->sx, tx);            /* pointer position */
  79.     y = fmul (h->sy, tx);
  80.     if (a < -DEG(5)) {
  81.         x = -x;
  82.         y = -y;
  83.     } else if (a < DEG(5)) {
  84.         x = muldiv (x, a, DEG(5));
  85.         y = muldiv (y, a, DEG(5));
  86.     }
  87.     x = fmul (x, p->cosy);
  88.     y = fmul (y, p->siny);
  89.     x = h->orgx + h->VV[X] + x;
  90.     y = h->orgy - h->VV[Y] - y;
  91.  
  92.     tx = 4*h->tx;                /* pointer size */
  93.     ty = 4*h->ty;
  94.     rx = tx/4;                /* circle radius */
  95.     ry = ty/4;
  96.     tx = fmul (tx, SIN(a));
  97.     ty = fmul (ty, COS(a));
  98.  
  99. #if 0
  100.     if (is_in (h, x, y, rx, ry) && is_in (h, x+tx, y-ty, 0, 0))
  101. #else
  102.     if (x > h->right-rx)
  103.         x = h->right-rx;
  104.     else if (x < h->left+rx)
  105.         x = h->left+rx;
  106.     if (y < h->top+ry)
  107.         y = h->top+ry;
  108.     else if (y > h->bottom-ry)
  109.         y = h->bottom-ry;
  110.  
  111.     if (x > h->right-tx)
  112.         x = h->right-tx;
  113.     else if (x < h->left-tx)
  114.         x = h->left-tx;
  115.     if (y < h->top+ty)
  116.         y = h->top+ty;
  117.     else if (y > h->bottom+ty)
  118.         y = h->bottom+ty;
  119. #endif
  120.         show_ptr (x, y, rx, ry, tx, ty, ST_HFG,
  121.             (EX->hud1 & HUD_TYPES) != HUD_CLASSIC);
  122. }
  123.